package team.away.android.fubway;

import java.io.IOException;

import org.anddev.andengine.audio.music.Music;
import org.anddev.andengine.audio.music.MusicFactory;
import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.scene.Scene.IOnAreaTouchListener;
import org.anddev.andengine.entity.scene.Scene.ITouchArea;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.input.touch.TouchEvent;
import org.anddev.andengine.util.Debug;

/**
 * (c) 2010 Nicolas Gramlich
 * (c) 2011 Zynga
 *
 * @author Nicolas Gramlich
 * @since 15:51:47 - 13.06.2010
 */
public class BackGroundMusic extends BaseExample {
	
	private Music mMusic;
	public EngineOptions engineOptions;
	private String mMusicloaction;
    public BackGroundMusic(EngineOptions Options,String mMusicLocation){
    	engineOptions=Options;
    	mMusicloaction=mMusicLocation;
    	onLoadEngine();
    	onLoadResources();
    	onLoadScene();
    	
    }
	// ===========================================================
	// Constructors
	// ===========================================================

	// ===========================================================
	// Getter & Setter
	// ===========================================================

	// ===========================================================
	// Methods for/from SuperClass/Interfaces
	// ===========================================================
	@Override
	public Engine onLoadEngine() {
		engineOptions.setNeedsMusic(true);
		return new Engine(engineOptions);
	}

	@Override
	public void onLoadResources() {
		
		MusicFactory.setAssetBasePath("mfx/");
		try {
			String mMusicLocation;
			this.mMusic = MusicFactory.createMusicFromAsset(this.mEngine.getMusicManager(), this,mMusicloaction);
			this.mMusic.setLooping(true);
		} catch (final IOException e) {
			Debug.e(e);
		}
	}

	@Override
	public Scene onLoadScene() {
		final Scene scene = new Scene();
		BackGroundMusic.this.mMusic.play();
		return scene;
	}

	@Override
	public void onLoadComplete() {

	}


}
